package com.lu.pojo.thread.status;

/**
 * @author luzhenfang
 * @date 2020 05 24
 * @description 线程守护
 * 虚拟机不用等待守护线程执行完毕
 */
public class ThreadDaemon {
    public static void main(String[] args) {
        God god = new God();
        You you = new You();
        // 上帝守护线程
        Thread thread = new Thread(god);
        thread.setDaemon(true);
        thread.start();
        // 用户线程
        new Thread(you).start();
    }
}

// 上帝
class God implements Runnable{
    @Override
    public void run() {
        while (true){
            System.out.println("God Bless You!");
        }
    }
}


// 人生不过三万天
class You implements Runnable{

    @Override
    public void run() {
        for (int i = 0; i < 30000; i++) {
            System.out.println("你一生都开心的活着");
        }
        // Hello,World
        System.out.println("===============goodbye world！");
    }
}

